package com.card;

import java.util.Collections;
import java.util.Stack;

public class CardDeck 
{
	private Stack<Card> cards = null;
	
	public CardDeck()
	{
		this.cards = new Stack<Card>();

		this.setCardsOf(Card.SHAPE_SPADE);
		this.setCardsOf(Card.SHAPE_CLOVER);
		this.setCardsOf(Card.SHAPE_DIAMOND);
		this.setCardsOf(Card.SHAPE_HEART);
		
		Collections.shuffle(this.cards);
	}
	
	private void setCardsOf(int cardShape)
	{
		for(int number = Card.NUMBER_A; number <= Card.NUMBER_K; number++)
		{
			this.cards.add(new Card(cardShape, number));
		}		
	}
	
	public Card getRandomCard()
	{
		return this.cards.pop();
	}
	
	public void retrieveCard(Card card)
	{
		this.cards.add(card);
	}
}